from asyncio.log import logger
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from conf.settings import *

#logger.info(DBConfig['userdb']['HOST'])
#SQLALCHEMY_DATABASE_URL = "mysql+pymysql://whitimeuser:Muli1234@rm-wz9d6pobocgz1e0j89o.mysql.rds.aliyuncs.com:3306/whitime?charset=utf8mb4"
#SQLALCHEMY_DATABASE_URL = "mysql+pymysql://apiuser:10.1.0.11:3306/userbase?charset=utf8mb4"
#SQLALCHEMY_DATABASE_URL = "mysql+pymysql://apiuser:tdsql-3c6vdu6l.sql.tencentcdb.com:150/userbase?charset=utf8mb4"
SQLALCHEMY_DATABASE_URL1 = "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8mb4".format(DBConfig['companydb']['USER'],DBConfig['companydb']['PASSWORD'],DBConfig['companydb']['HOST'],DBConfig['companydb']['PORT'],DBConfig['companydb']['DATABASE'])

engine1 = create_engine(SQLALCHEMY_DATABASE_URL1, max_overflow=5)

SessionLocal1 = sessionmaker(autocommit=False, autoflush=False, bind=engine1)

Base1 = declarative_base()

def testdb():
    session =SessionLocal1()
    cursor= session.execute('show databases')
    result = cursor.fetchall()
    print(result)